package com.hoshiicloud.mallshop.feign.hystrix;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hoshiicloud.common.query.OmnipotentWrapper;
import com.hoshiicloud.common.rpc.Response;
import com.hoshiicloud.mallshop.feign.ShopUserFeignService;
import com.hoshiicloud.user.dto.userCenter.MemberDto;
import com.hoshiicloud.user.entity.company.Member;
import com.hoshiicloud.user.entity.store.PlatStore;
import com.hoshiicloud.user.entity.visitors.Visitors;
import com.hoshiicloud.user.param.PlatStoreConsumerPageParam;
import com.hoshiicloud.user.param.PlatStoreQueryParam;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * 2019/8/12 17:30 qry
 */
@Slf4j
public class ShopUserFeignServiceFallback implements FallbackFactory<ShopUserFeignService> {

    @Override
    public ShopUserFeignService create(Throwable throwable) {
        log.error("出现异常" + throwable.getMessage());
        return new ShopUserFeignService() {
            @Override
            public Response<Member> getMembersById(Long id) {
                return Response.failed("获取会员信息失败"+ throwable.getMessage());
            }

            @Override
            public Response<List<Member>> getMembersByIds(List<Long> ids) {
                return Response.failed("根据memberId集合获取会员信息失败"+ throwable.getMessage());
            }

            @Override
            public Response<PlatStore> getPlatStoreById(Long id) {
                return Response.failed("根据店铺ID获取店铺信息失败"+ throwable.getMessage());
            }

            @Override
            public Response<Page<PlatStore>> getPlatStorePage(PlatStoreQueryParam param) {
                return Response.failed("根据条件查询店铺的分页信息失败"+ throwable.getMessage());
            }

            @Override
            public Response<List<PlatStore>> listBranchStore(Long storeId) {
                return Response.failed("通过总店Id查询其分店失败"+ throwable.getMessage());
            }

            @Override
            public Response<Page<MemberDto>> getStoreConsumersPage(PlatStoreConsumerPageParam param) {
                return Response.failed("根据平台台消费者信息分页查询会员信息失败"+ throwable.getMessage());
            }

            @Override
            public Response<List<Visitors>> queryVisitorsBatch(List<OmnipotentWrapper> param) {
                return Response.failed("批量查询访客数信息失败"+ throwable.getMessage());
            }

        };
    }
}
